/*
 * init.h
 *
 *  Created on: 17 sept. 2013
 *      Author: the
 */

#ifndef INIT_H_
#define INIT_H_
#include "type.h"
#include "metric.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//Global extern variables
extern int nbOfNodes;		//Number of nodes
extern struct node* nodes;	//Array with the nodes
extern int nbOfRadios;		//Number of radios per node
extern int maxFreq;		//Number of orthogonal frequencies
extern int algorithm;		//Algorithm number used to allocate the frequencies
extern float	L;		//Length of a side of the observation window (LxL)
extern float	R;		//Radio scope of the nodes

// The Anh
extern int disjointPaths; //If 1 there is only one route per node - If 0 we may have several routes using the same node
extern int directionnels; //If 1 there is conflict directionnels - If 0 there is bidirectionnels
// Fin The Anh

//Print error for the call system
void error(char * string);

//Initialize the different entries of the node "id".
void initNode(int id, int variant);
//Malloc the ressource for the routing table and initialize it (with -1)
struct routingEntry* initRoutingTable(int id);
//Free the ressource (the two mallocs) for node id
void freeNodes();
//indicates if the node id1 is in the neighborhood of node id2
//return 1 if yes and 0 otrherwise
int isNeighbor(int id1, int id2);
//indicates if the node id1 is in the 2-neighborhood of node id2
//return 1 if yes and 0 otrherwise
int is2Neighbor(int id1, int id2);
//Get the Wi-Fi rate between nodes id1 and id2 with regard to the distance
int getMetric(int id1, int id2);
//Update the neighborhood for node id
int updateN1(int id);
//Update the 2-neighborhood for node id
int updateN2(int id);
//Initialize the array nodes (id, locations, N1 and N2) and allocate the memory for the routing table.
//Frequency are not assigned and the routing table is not compute.
void initArrayNodes(int variant);
//Print the fields of the nodes in the array nodes
void printArrayNodes();



#endif /* INIT_H_ */
